package cn.jeeweb.modules.web.labor.service.impl;

import cn.jeeweb.core.common.service.impl.CommonServiceImpl;
import cn.jeeweb.core.query.data.Page;
import cn.jeeweb.core.query.data.PageImpl;
import cn.jeeweb.core.query.data.Pageable;
import cn.jeeweb.core.query.data.Queryable;
import cn.jeeweb.core.query.parse.QueryToWrapper;
import cn.jeeweb.modules.web.labor.content.HuSubjectContent;
import cn.jeeweb.modules.web.labor.content.HuSubsidyContent;
import cn.jeeweb.modules.web.labor.mapper.HuSubsidyCategoryMapper;
import cn.jeeweb.modules.web.labor.entity.HuSubsidyCategory;
import cn.jeeweb.modules.web.labor.service.IHuSubsidyCategoryService;
import com.baomidou.mybatisplus.mapper.Wrapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**   
 * @Title: hu_subsidy_category
 * @Description: hu_subsidy_category
 * @author rql
 * @date 2018-02-09 18:15:18
 * @version V1.0   
 *
 */
@Transactional
@Service("huSubsidyCategoryService")
public class HuSubsidyCategoryServiceImpl  extends CommonServiceImpl<HuSubsidyCategoryMapper,HuSubsidyCategory> implements  IHuSubsidyCategoryService {

    @Resource
    private HuSubsidyCategoryMapper huSubsidyCategoryMapper;

    public Page<HuSubsidyContent> selectSubsidyPage(Queryable queryable, Wrapper<HuSubsidyContent> wrapper){
        QueryToWrapper<HuSubsidyContent> queryToWrapper = new QueryToWrapper<HuSubsidyContent>();
        queryToWrapper.parseCondition(wrapper, queryable);
        // 排序问题
        queryToWrapper.parseSort(wrapper, queryable);
        Pageable pageable = queryable.getPageable();
        com.baomidou.mybatisplus.plugins.Page<HuSubsidyContent> content = new com.baomidou.mybatisplus.plugins.Page<HuSubsidyContent>(
                pageable.getPageNumber(), pageable.getPageSize());
        List<HuSubsidyContent> list=huSubsidyCategoryMapper.selectSubsidyPage(content);
        content.setRecords(list);
        return new PageImpl<HuSubsidyContent>(content.getRecords(), queryable.getPageable(), content.getTotal());
    }

    public HuSubsidyCategory  selectSubsidy(String cateId){
        return huSubsidyCategoryMapper.selectSubsidy(cateId);
    }




}
